<?php
/**
 * 地址模块 控制器
 *
 * @author    wangmx <wangmx@yunys.com.cn>
 * @copyright 2016 QuanZhouYunYiShang Inc.
 */
namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Response;
use App\Services\UserService\AddressService;

class AddressController extends BaseController
{
    protected $address;

    public function __construct(AddressService $addressService)
    {
        $this->address = $addressService;
    }

    /**
     * 添加收货地址
     * user_id  consignee收货人 phone电话  city城市  address详细地址
     */
    public function addAddress(Request $request)
    {
        $result = $this->address->addAddress($request);
        return Response::json($result);
    }

    /**
     * 设置默认收货地址
     * user_id  address_id
     */
    public function setDefault(Request $request)
    {
        $result = $this->address->setDefault($request);
        return Response::json($result);
    }

    /**
     * 修改收货地址信息
     * address_id  consignee收货人 phone电话  city城市  address详细地址
     */
    public function editAddress(Request $request)
    {
        $result = $this->address->editAddress($request);
        return Response::json($result);
    }

    /**
     * 删除收货地址
     * address_id user_id
     */
    public function deleteAddress(Request $request)
    {
        $result = $this->address->deleteAddress($request);
        return Response::json($result);
    }
    
    /**
     * 收货地址列表
     * user_id
     */
    public function addressList(Request $request){
        $result = $this->address->addressList($request);
        return Response::json($result);
    }

    /**
     * 根据address_id获取收货地址信息
     * address_id
     */
    public function addressById(Request $request){
        $result = $this->address->addressByID($request);
        return Response::json($result);
    }
}